package org.restorator.entity;

/**
 * @author Snisar Bogdan.
 */
public class Item {

    public Item() { }

    public Item(int itemId, String name, double price, String categoryName, String description) {
        this.itemId = itemId;
        this.name = name;
        this.price = price;
        this.categoryName = categoryName;
        this.description = description;
    }

    private int itemId;
    private String name;
    private double price;
    private String categoryName;
    private String description;

    public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public double getPrice() {
        return price;
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null) {
            return false;
        }
        if(obj == this) {
            return true;
        }
        if(obj instanceof Item) {
            Item itm = (Item) obj;
            return this.itemId == itm.itemId &&
                    this.name.equals(itm.name) &&
                    this.price == itm.price &&
                    this.categoryName.equals(itm.categoryName) &&
                    this.description.equals(itm.description);
        }
        return false;
    }
    
    
    
    @Override
    public String toString() {
        return "Item={ " + "Id = "+this.itemId + "Name = "+ this.name + "Desc = "+this.description+ "Price = "+this.price+ "Category = "+this.categoryName+ '}';
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((categoryName == null) ? 0 : categoryName.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + itemId;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		long temp;
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

}
